package com.neusoft.service.impl;

import com.neusoft.mapper.DisposalRequestMapper;
import com.neusoft.mapper.InspectionRequestMapper;
import com.neusoft.mapper.MedicalTechnologyMapper;
import com.neusoft.service.DisposalRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Service
public class DisposalRequestServiceImpl implements DisposalRequestService {

    @Autowired
    DisposalRequestMapper disposalRequestMapper;

    @Autowired
    MedicalTechnologyMapper medicalTechnologyMapper;

    @Override
    public String saveInspectionRequest(Map<String, Object> disposalRequest) {
        List<Map<String,Object>> checkMedicalTechnologyList=(List<Map<String, Object>>) disposalRequest.get("checkMedicalTechnologyList");

        if (checkMedicalTechnologyList.size()>0){
            for (int i=0;i<checkMedicalTechnologyList.size();i++){
                Map<String,Object> element=checkMedicalTechnologyList.get(i);
                disposalRequest.put("medical_technology_id",element.get("id"));
                disposalRequest.put("disposal_state","已缴费");
                // checkRequest.put("checkMedicalTechnologyList",element);
                disposalRequestMapper.insert(disposalRequest);
            }
        }
        return "成功";
    }

    @Override
    public Integer getFinishDisposal() {
        return disposalRequestMapper.selectFinshDisposal();
    }

    @Override
    public List<Integer> getWaitRegisterIdList() {

        return disposalRequestMapper.selectWaitDisposal();
    }

    @Override
    public void updateDisposalRequestTable(Integer disposalId, Integer employeeId) {
        LocalDateTime disposalTime=LocalDateTime.now();
        disposalRequestMapper.updateDisposalRequestTable(disposalId,employeeId,disposalTime);
    }

    @Override
    public List<Map<String, Object>> searchDisposalItems(Integer registerId) {
        return disposalRequestMapper.selectDisposalItem(registerId);
    }
}
